package com.zxy.ziems.server.statistics.controller;

import com.zxy.ziems.server.constant.enums.DictCodeEnum;
import com.zxy.ziems.server.dto.DataQueryDto;
import com.zxy.ziems.server.energy.service.DataChartDictService;
import com.zxy.ziems.server.vo.ChartVo;
import com.zxy.ziems.server.vo.PieChartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 碳排放
 *
 * @author chdzq
 * @create 2023/4/13
 */
@RestController
@Validated
@RequestMapping("/api/carbon/emission")
public class CarbonEmissionController {


    @Autowired
    private DataChartDictService dataChartDictService;

    /**
     * 碳排放线性
     *
     * @return
     */
    @GetMapping("/totalLine")
    public ChartVo totalLine(DataQueryDto dataQueryDto) {
        dataQueryDto.setDictCode(DictCodeEnum.CARBON_EMISSION.getCode());
        dataQueryDto.setItemName("碳排放");
        return dataChartDictService.thisData(dataQueryDto);
    }

    /**
     * 碳排放分类线性
     *
     * @return
     */
    @GetMapping("/totalTypeLine")
    public ChartVo totalTypeLine(DataQueryDto dataQueryDto) {
        dataQueryDto.setDictCode(DictCodeEnum.CARBON_EMISSION.getCode());
        dataQueryDto.setItemName("碳排放");
        return dataChartDictService.childData(dataQueryDto);
    }

    /**
     * 碳排放占比分析
     *
     * @return
     */
    @GetMapping("/totalTypePie")
    public List<PieChartVo> totalTypePie(DataQueryDto dataQueryDto) {
        dataQueryDto.setDictCode(DictCodeEnum.CARBON_EMISSION.getCode());
        dataQueryDto.setItemName("碳排放");
        return dataChartDictService.totalTypePie(dataQueryDto);
    }


}

